package sprites;

import java.awt.Point;
import vista.ZonaDeJoc;

/**
 *
 * @author Carlos Moya Martinez
 */
public abstract class PlayableElement extends Sprite {

    protected int vides;
    protected boolean enemic; /*Enemic del jugador o no*/
    protected int puntos = 0;


    public PlayableElement(Point pantalla) {
        super(pantalla);
    }

    public PlayableElement(int vides, boolean enemic, Point pantalla) {
        super(pantalla);
        this.vides = vides;
        this.enemic = enemic;
    }

    public PlayableElement(int x, int y, Point pantalla) {
        super(x, y, pantalla);
    }

    public PlayableElement(int vides, boolean enemic, int x, int y, Point pantalla) {
        super(x, y, pantalla);
        this.vides = vides;
        this.enemic = enemic;
    }

    public boolean isEnemic() {
        return enemic;
    }

    public boolean isDead() {
        return this.getVides() <= 0;
    }

    public int getVides() {
        return vides;
    }

    public void setEnemic(boolean enemic) {
        this.enemic = enemic;
    }

    public void setVides(int vides) {
        this.vides = vides;
    }

    public int getPuntos() {
        return puntos;
    }

    public void setPuntos(int puntos) {
        this.puntos = puntos;
    }

    public boolean collision(PlayableElement objecteB) {
        if (ZonaDeJoc.collision(this, objecteB) && (objecteB.isEnemic() != this.enemic )) {
            this.setVides(vides - 1);
            //System.out.println(this.getClass().getName()+"("+this.vides + ") VS " + objecteB.getClass().getName()+"("+objecteB.vides + ")");
        }
        return true;
    }
}
